import moment from 'moment'

const STATUS = {
  0: '已过期',
  1: '分享成功',
  // 2: '已领取',
  3: '已发货',
  4: '已完成'
}

const STATUSDisplay = {
  0: 'error',
  1: 'success',
  3: 'success',
  4: 'success'
}

export default {
  filters: {
    shareStatusFilter (status, etime) {
      const isOverDate = moment(etime).isBefore(new Date())
      if (isOverDate) {
        status = 4
      }
      return STATUS[status]
    }
  },
  methods: {
    shareStatusDisplay (status, etime) {
      const isOverDate = moment(etime).isBefore(new Date())
      if (isOverDate) {
        status = 4
      }

      return STATUSDisplay[status]
    }
  }
}
